package live.jialing.sip.base.domain;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import live.jialing.core.beanvalidator.First;
import live.jialing.core.beanvalidator.Second;
import live.jialing.sip.base.dict.ClassCategoryEnum;
import live.jialing.structure.domain.Party;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 年级组
 */
@Setter
@Getter
@ToString
@Entity
@DiscriminatorValue("user_group_grade")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id",scope = GradeGroup.class)
public class GradeGroup extends Party {

    /**
     * 入学年份
     */
    @NotNull(message = "入学年份不能为空", groups = {First.class, Second.class})
    private Integer grade;

    /**
     * 班级分类
     */
    @NotNull(message = "班级类型不能为空", groups = {First.class, Second.class})
    @Enumerated(EnumType.STRING)
    private ClassCategoryEnum category;

    /**
     * 学校
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", updatable = false)
    @NotNull(message = "学校不能为空", groups = {First.class, Second.class})
    private School school;

}
